<?php require VIEW_PATH."/header.php";?>
<body>
<link rel="stylesheet" href="Public/org/kindeditor/themes/default/default.css" />
<script src="Public/org/kindeditor/kindeditor.js"></script>
<script src="Public/org/kindeditor/lang/zh_CN.js"></script>
<form method="post" enctype="multipart/form-data">
<!-- 面板切换 -->
<div class="hd-tab">
<ul class="hd-tab-menu">
    <li lab="base" class="active">
        <a> 基本设置 </a>
    </li>
    <li lab="shop_pic">
        <a>商品图集 </a>
    </li>
    <li lab="shop_value">
        <a>商品属性 </a>
    </li>
    <li lab="shop_detail">
        <a>商品详情 </a>
    </li>
</ul>


<div class="hd-tab-content">
<!-- 第一面板 -->
    <div lab="base" class="hd-tab-area">            
            <table class="hd-table hd-table-form hd-form">
                <thead>
                <tr>
                    <td colspan="2">添加商品</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th>父级</th>
                    <td>
                        <select name="cat_id">
                            {{foreach from="$catData" value="$v"}}
                         <option value="{{$v['cat_id']}}">{{$v['_name']}}</option>
                            {{endforeach}}              
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>商品名称</th>
                    <td>
                        <input type="text" name="goods_name" class="hd-w300">
                    </td>
                </tr>
               <tr>
                    <th>货号</th>
                    <td>
                        <input type="text" name="goods_sn" class="hd-w300">
                    </td>
                </tr>
                <tr>
                    <th>单位</th>
                    <td>
                        <input type="text" name="unit" class="hd-w300">
                    </td>
                </tr>
                <tr>
                    <th>品牌</th>
                    <td>
                    <select name="brand_id">
                    {{foreach from="$brandData" value="$field"}}
                        <option value="{{$field['id']}}">{{$field['name']}}</option>
                    {{endforeach}}
                    </select>
                    </td>
                </tr>
                <tr>
                    <th>点击数</th>
                    <td>
                        <input type="text" name="click" class="hd-w300">
                    </td>
                </tr>
                <tr>
                    <th>列表页图</th>
                    <td>
                        <input type="file" name="list_pic" class="hd-w300">
                    </td>
                </tr>
                <tr>
                    <th>缩略图</th>
                    <td>
                       <input type="file" name="thumb_pic" class="hd-w300">
                    </td>
                </tr>
                <tr>
                    <th>商品关键词</th>
                    <td>
                        <input type="text" name="keyword" class="hd-w300">
                    </td>
                </tr>
                <tr>
                    <th>商品描述</th>
                    <td>
                        <textarea name="description" class="hd-w300 hd-h100"></textarea>
                    </td>
                </tr>                    
                </tbody>
            </table>            
    </div>
    <!-- 第一面板end -->
    <!-- 商品图集 -->
    <div lab="shop_pic" class="hd-tab-area">
        <table >
            <tr>
                <td style="height: 40px;">
                    <input type="file" name="pics[]" style="display:inline-block">
                    <button type="button" onclick="addPic(this)" style="display:inline-block;box-shadow: 0 0 5px #ccc;border-radius: 0;font-weight: bold;" class="btn btn-warning">＋</button>
                </td>
            </tr>
        </table>
    </div>
    <!-- 商品图集end -->

    <!-- 商品属性 -->
    <div lab="shop_value" class="hd-tab-area">
        <table class="hd-table hd-table-form hd-form">
            <thead>
                <tr>
                    <td colspan="2">商品属性设置</td>
                </tr>
            </thead>
            <tr>
                <th style="width:300px;text-align: rigth;">商品类型</th>
                <td>
                    <select name="type_id" onchange="getAttrList()">
                    <option value="">===请选择商品类型===</option>
                    {{foreach from="$shopType" value="$field"}}
                        <option value="{{$field['id']}}">{{$field['type_name']}}</option>
                    {{endforeach}}
                    </select>
                    <!-- 温馨提示 -->
                    <span style="font-weight: bold;span">
                        <label style="color:red;">*</label>
                     &nbsp;温馨提示，请选择类型后，根据需要填写商品属性
                    </span>
                    <!-- 温馨提示end --> 
                </td>
            </tr>
            <!-- 内容区 -->
            <tr>
                <td colspan="2" style="padding:0;margin: 0;">
                    <p style="background: #ec971f;height: 10px;padding:0;margin: 0;"></p>
                    <!-- 内容插入表单 -->
                    <table id="attr_list" class="hd-table hd-table-form hd-form">
                         
                    </table>
                    <!-- 内容插入表单end -->
                </td>
            </tr>
            <!-- 内容区end -->
        </table>
    </div>
    <!-- 商品属性end -->

    <!-- 商品详情 -->
    <div lab="shop_detail" class="hd-tab-area">
        <table class="hd-table hd-table-form hd-form">
            <thead>
                <tr>
                    <td colspan="2">商品详情</td>
                </tr>
            </thead>
            <tr>
                <th>商品详情</th>
                <td>
                   <textarea name="content" id="content" style="width:800px;height:400px;visibility:hidden;"></textarea> 
                </td>
            </tr>
            <tr>
                <th>售后服务</th>
                <td>
                   <textarea name="service" id="service" style="width:800px;height:400px;visibility:hidden;"></textarea> 
                </td>
            </tr>
        </table>
    </div>
    <!-- 商品详情end -->
</div>
</div>
<!-- 面板切换结束 -->
<div>
<td colspan="2">
    <button class="hd-btn hd-btn-primary">提交</button>
</td>
</div>
</form>
</body>
<script type="text/javascript">
// 点击按钮就往下新增一层
function addPic(obj)
{
    var table = $(obj).parents('table').eq(0);
    var tr = '<tr>';
    tr += "<td style='height:40px'>";
    tr += '<input type="file" name="pics[]" style="display:inline-block">&nbsp;';
    tr += '<button type="button" onclick="removePic(this)" style="display:inline-block;box-shadow: 0 0 5px #ccc;border-radius: 0;font-weight: bold;padding:6px 12px;" class="btn btn-info">－</button></td></tr>';
    table.append(tr);
}

// 点击按钮就移除一个是上传框
function removePic(obj)
{
    $(obj).parents('tr').eq(0).remove();
}
</script>
<script type="text/javascript">
// 找到指定id生成编辑器
KindEditor.ready(function(K) {
    window.editor = K.create('#content');
    window.editor = K.create('#service');
});
</script>
<script type="text/javascript">
//按照类型抽取对应的属性列表
    function getAttrList()
    {
        //定义变量。获取到模版上的值
        var type_id = $('[name=type_id]').val();
        $.ajax({
            url:'index.php?m=Admin&c=Goods&a=getAttrList',
            data:{type_id:type_id},
            type:'get',
            success:function(data){
                $('#attr_list').html(data);
            }
        });
    }
</script>
</html>
